﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Newtonsoft.Json;

public partial class Rep_DayRep : System.Web.UI.Page
{
    BLL.BLLRep br = new BLL.BLLRep();
    private static string pName = "";
    private static int unit = 0;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (pName == null || pName == "")
            {
                string name = getTableName(Request.QueryString["name"]);
                int id = Convert.ToInt32(Request.QueryString["unit"]);
                pName = name;
                unit = id;
            }
        }

        //string param = Request["param"];
        //if (param != null)
        //{
        //    if (param == "query")
        //    {
        //        string time = Request["time"];
        //        QueryTableList(pName, unit, time);
        //    }
        //}
    }
    protected void QueryTableList(string pName, int unit, string time)
    {
        DateTime nTime = DateTime.Now;
        if (nTime.Year == Convert.ToDateTime(time).Year && nTime.Month == Convert.ToDateTime(time).Month && nTime.Day == Convert.ToDateTime(time).Day && Convert.ToDateTime(time).Hour != 24)
            time += " " + DateTime.Now.Hour + ":00:00";

        string strApp = br.RetTableByDayInfo(pName, unit, Convert.ToDateTime(time));
        dvShow.InnerHtml = strApp;
        //object obj = new { tableInfo = strApp };
        //string result = JavaScriptConvert.SerializeObject(obj);
        //Response.Write(result);
        //Response.End();
    }
    private string getTableName(string id)
    {
        string tableName = "";
        if (id == "1")
            tableName = "报表一";
        else if (id == "2")
            tableName = "报表二";
        else if (id == "3")
            tableName = "报表三";
        else if (id == "4")
            tableName = "报表四";
        else if (id == "5")
            tableName = "报表五";
        else if (id == "6")
            tableName = "报表六";
        else if (id == "7")
            tableName = "报表七";
        else if (id == "8")
            tableName = "报表八";
        else if (id == "9")
            tableName = "报表九";
        else if (id == "10")
            tableName = "报表十";
        else if (id == "11")
            tableName = "报表十一";
        else if (id == "12")
            tableName = "报表十二";
        else if (id == "13")
            tableName = "报表十三";
        else if (id == "14")
            tableName = "报表十四";
        else if (id == "15")
            tableName = "报表十五";
        else if (id == "16")
            tableName = "报表十六";
        else if (id == "17")
            tableName = "报表十七";
        else if (id == "18")
            tableName = "报表十八";
        return tableName;
    }
    protected void btnChaXun_Click(object sender, EventArgs e)
    {
        QueryTableList(pName, unit, txtDate.Value.Trim());
    }
}
